package com.jie.singleton;

/**
 * 双重校验锁
 * 懒加载线程安全
 * @author jie
 * @date 2019/11/6 -11:45
 */
public class DoubleCheckedLocking {
    private volatile static DoubleCheckedLocking singleton;

    private DoubleCheckedLocking() {
    }

    public static DoubleCheckedLocking getSingleton() {
        if (singleton == null) {
            synchronized (DoubleCheckedLocking.class) {
                if (singleton == null) {
                    singleton = new DoubleCheckedLocking();
                }
            }
        }
        return singleton;
    }
}
